package com.xiaoshuidi.cloud.module.rooms.api;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.util.json.JsonUtils;
import com.xiaoshuidi.cloud.module.contract.enums.contract.ContractStatusEnum;
import com.xiaoshuidi.cloud.module.rooms.api.roomstate.RoomStateRecordApi;
import com.xiaoshuidi.cloud.module.rooms.api.roomstate.dto.UpdateRoomStateReqDTO;
import com.xiaoshuidi.cloud.module.rooms.api.roomstate.vo.GetCurrentRecordRespVO;
import com.xiaoshuidi.cloud.module.rooms.api.roomstate.vo.UpdateRoomTenantReqVO;
import com.xiaoshuidi.cloud.module.rooms.service.RoomStateRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.xiaoshuidi.cloud.module.contract.enums.contract.ContractStatusEnum.NO_SIGNED;
import static com.xiaoshuidi.cloud.module.system.enums.ApiConstants.VERSION;

/**
 * @author hans.zhang
 */
@RestController
@DubboService(version = VERSION)
@Validated
@Slf4j
@RequiredArgsConstructor
public class RoomStateRecordApiImpl implements RoomStateRecordApi {


    private final RoomStateRecordService roomStateRecordService;

    @Override
    public CommonResult<GetCurrentRecordRespVO> getCurrentRecord(Long roomHouseId) {
        return roomStateRecordService.getCurrentRecord(roomHouseId);
    }

    /**
     * 根据合同状态修改房态
     * @param updateRoomStateReqDTOS
     * @return
     */
    @Override
    public CommonResult<Boolean> updateRoomStateByContract(UpdateRoomStateReqDTO updateRoomStateReqDTOS) {
        log.info("合同修改房态接口被调用,请求参数:{}", JsonUtils.toJsonString(updateRoomStateReqDTOS));
        return roomStateRecordService.updateRoomStateByContract(updateRoomStateReqDTOS);
    }

    /**
     * 批量根据合同状态修改房态
     * @return
     */
    @Override
    public CommonResult<Boolean> updateRoomStateByContract(List<UpdateRoomStateReqDTO> updateRoomStateReqDTOS) {
        log.info("批量合同修改房态接口被调用,请求参数:{}", JsonUtils.toJsonString(updateRoomStateReqDTOS));
        return roomStateRecordService.updateRoomStateByContract(updateRoomStateReqDTOS);
    }

    /**
     * 修改租住人/同住人信息
     * @param updateRoomTenantReqVO
     * @return
     */
    @Override
    public CommonResult<Boolean> updateRoomTenant(UpdateRoomTenantReqVO updateRoomTenantReqVO) {
        log.info("修改租住人/同住人信息api接口被调用,请求参数:{}", JsonUtils.toJsonString(updateRoomTenantReqVO));
        return roomStateRecordService.updateRoomTenant(updateRoomTenantReqVO);
    }

    //    @Override
//    public CommonResult<Long> saveRecord(Long roomHouseId, String state) {
//        return roomStateRecordService.saveRecord(roomHouseId, state);
//    }


}
